home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / TCP_IP / TNOS230S / IFACE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-09-06  |  7.3 KB  |  223 lines

  1. #ifndef    _IFACE_H
  2. #define    _IFACE_H
  3.  
  4. #ifndef    _GLOBAL_H
  5. #include "global.h"
  6. #endif
  7.  
  8. #ifndef    _MBUF_H
  9. #include "mbuf.h"
  10. #endif
  11.  
  12. #ifndef _PROC_H
  13. #include "proc.h"
  14. #endif
  15.  
  16. #ifdef __GNUC__
  17. struct iface;            /* forward declaration for gcc */
  18. #endif
  19.  
  20. #ifndef _TCP_H
  21. #include "tcp.h"
  22. #endif
  23.    
  24. #ifdef AX25
  25. #ifndef _AX25_H
  26. #include "ax25.h"
  27. #endif
  28. #endif
  29.  
  30. /* Interface encapsulation mode table entry. An array of these structures
  31.  * are initialized in config.c with all of the information necessary
  32.  * to attach a device.
  33.  */
  34.  
  35. #if !defined(send) && !defined(_SOCKET_H)
  36. /* ugly hack to avoid both libc collisions and jnos misconnections */
  37. #include "socket.h"
  38. #endif
  39.  
  40.  
  41. struct iftype {
  42.     const char *name;    /* Name of encapsulation technique */
  43.     int (*send) (struct mbuf *,struct iface *,uint32,int,int,int,int);
  44.                 /* Routine to send an IP datagram */
  45.     int (*output) (struct iface *,const char *,char *,int16,struct mbuf *);
  46.                 /* Routine to send link packet */
  47.     char *(*format) (char *,char *);
  48.                 /* Function that formats addresses */
  49.     int (*scan) (char *,const char *);
  50.                 /* Reverse of format */
  51.     int type;        /* Type field for network process */
  52.     int hwalen;        /* Length of hardware address, if any */
  53. };
  54. #define    NULLIFT    (struct iftype *)0
  55. extern struct iftype Iftypes[];
  56.  
  57.  
  58. #ifdef AX25    /* placed here to prevent interdependency problems w/header files */
  59. struct ax25_counters    {
  60.     int32    msgin;
  61.     int32    msgout;
  62.     int32    datain;
  63.     int32    dataout;
  64.     int32    segin;
  65.     int32    segout;
  66.     int32    segerr;
  67.     int32    frmerr;
  68.     int32    rnrin;
  69.     int32    rejin;
  70.     int32    rnrout;
  71.     int32    rejout;
  72.     int32    retries;
  73. };
  74. #endif
  75.  
  76.  
  77. /* Interface control structure */
  78. struct iface {
  79.     struct iface *next;    /* Linked list pointer */
  80.     const char *name;    /* Ascii string with interface name */
  81.     char *descr;        /* Description of interface */
  82.  
  83.     uint32 addr;        /* IP address */
  84.     uint32 broadcast;    /* Broadcast address */
  85.     uint32 netmask;        /* Network mask */
  86.   
  87.     int16 mtu;        /* Maximum transmission unit size */
  88.         /*  
  89.         **      Interface Metric - this value is used by RIP
  90.         **      to determine what value to increment the RIP_TTL
  91.         **      by.  This is a simple hack to allow specifying that
  92.         **      some interfaces are of higher quality than others.
  93.         **
  94.         */
  95.     int iface_metric;
  96.  
  97.     int32 flags;        /* Configuration flags */
  98. #define DATAGRAM_MODE   0L    /* Send datagrams in raw link frames */
  99. #define CONNECT_MODE    1L    /* Send datagrams in connected mode */
  100. #define IS_NR_IFACE     2L    /* Activated for NET/ROM - WG7J */
  101. #define NR_VERBOSE      4L    /* NET/ROM broadcast is verbose - WG7J */
  102. #define IS_CONV_IFACE   8L    /* Activated for conference call access - WG7J */
  103. #define AX25_BEACON     16L    /* Broadcast AX.25 beacons */
  104. #define MAIL_BEACON     32L    /* Send MAIL beacons */
  105. #define HIDE_PORT       64L    /* Don't show port in PBBS P command */
  106. #define AX25_DIGI       128L    /* Allow digipeating */
  107. #define ARP_EAVESDROP   256L    /* Listen to ARP replies */
  108. #define ARP_KEEPALIVE   512L    /* Keep arp entries alive after timeout */
  109. #define LOG_AXHEARD    1024L    /* Do ax.25 heard logging on this interface */
  110. #define LOG_IPHEARD    2048L    /* Do IP heard logging on this interface */
  111. #define NO_AX25        4096L    /* No ax.25 PBBS connections on this port */
  112. #define BBS_ONLY       8192L    /* BBS's only in PBBS via this port */
  113. #define USERS_ONLY     16384L    /* Users only on this port */
  114. #define SYSOP_ONLY     32768L    /* Sysops only on this port */
  115. #define LOOPBACK_AX25  65536L    /* Used for AX25 loopback interface */
  116.  
  117. #ifdef NETROM
  118.     int quality;            /* Netrom interface quality */
  119. #endif
  120.  
  121.     int16 trace;        /* Trace flags */
  122. #define    IF_TRACE_OUT    0x01    /* Output packets */
  123. #define    IF_TRACE_IN    0x10    /* Packets to me except broadcast */
  124. #define    IF_TRACE_ASCII    0x100    /* Dump packets in ascii */
  125. #define    IF_TRACE_HEX    0x200    /* Dump packets in hex/ascii */
  126. #define    IF_TRACE_NOBC    0x1000    /* Suppress broadcasts */
  127. #define    IF_TRACE_RAW    0x2000    /* Raw dump, if supported */
  128.     char *trfile;        /* Trace file name, if any */
  129.     FILE *trfp;        /* Stream to trace to */
  130.     int trsock;        /* Socket to trace to */
  131.  
  132.     struct iface *forw;    /* Forwarding interface for output, if rx only */
  133. #ifdef RXECHO  
  134.     struct iface *rxecho;    /* Echo received packets here - WG7J */ 
  135. #endif
  136.  
  137.     struct proc *rxproc;    /* Receiver process, if any */
  138.     struct proc *txproc;    /* Transmitter process, if any */
  139.     struct proc *supv;    /* Supervisory process, if any */
  140.  
  141.     /* Device dependant */
  142.     int dev;        /* Subdevice number to pass to send */
  143.                 /* To device -- control */
  144.     int32 (*ioctl) (struct iface *,int cmd,int set,int32 val);
  145.                 /* From device -- when status changes */
  146.     int (*iostatus) (struct iface *,int cmd,int32 val);
  147.                 /* Call before detaching */
  148.     int (*stop) (struct iface *);
  149.     char *hwaddr;        /* Device hardware address, if any */
  150.     char *ipcall;        /* Device IP call sign, if any */
  151.     char *rmtaddr;        /* AXIP remote address, if any */
  152.  
  153.     /* Encapsulation dependant */
  154. #ifdef AX25
  155.     struct ifax25 *ax25;    /* Pointer to ax.25 protocol structure */
  156.     struct ax25_counters axcnt; /* AX25 counters */
  157. #endif
  158.     struct iftcp *tcp;      /* Tcp protocol variables */
  159.     void *edv;        /* Pointer to protocol extension block, if any */
  160.     int type;        /* Link header type for phdr */
  161.     int xdev;        /* Associated Slip or Nrs channel, if any */
  162.     int port;        /* Sub port for multy port kiss */
  163.     struct iftype *iftype;    /* Pointer to appropriate iftype entry */
  164.  
  165.                 /* Encapsulate an IP datagram */
  166.     int (*send) (struct mbuf *,struct iface *,uint32,int,int,int,int);
  167.                 /* Encapsulate any link packet */
  168.     int (*output) (struct iface *,const char *,char *,int16,struct mbuf *);
  169.                 /* Send raw packet */
  170.     int (*raw)        (struct iface *,struct mbuf *);
  171.                 /* Display status */
  172.     void (*show)        (struct iface *);
  173.  
  174.     int (*discard)        (struct iface *,struct mbuf *);
  175.     int (*echo)        (struct iface *,struct mbuf *);
  176.  
  177.     /* Counters */
  178.     int32 ipsndcnt;     /* IP datagrams sent */
  179.     int32 rawsndcnt;    /* Raw packets sent */
  180.     int32 iprecvcnt;    /* IP datagrams received */
  181.     int32 rawrecvcnt;    /* Raw packets received */
  182.     int32 lastsent;        /* Clock time of last send */
  183.     int32 lastrecv;        /* Clock time of last receive */
  184. };
  185. #define    NULLIF    (struct iface *)0
  186. extern struct iface *Ifaces;    /* Head of interface list */
  187. extern struct iface  Loopback;    /* Optional loopback interface */
  188. extern struct iface  Encap;    /* IP-in-IP pseudo interface */
  189.  
  190. /* Header put on front of each packet in input queue */
  191. struct phdr {
  192.     struct iface *iface;
  193.     unsigned short type;    /* Use pktdrvr "class" values */
  194. };
  195.  
  196. #if 0
  197. /* Header put on front of each packet sent to an interface */
  198. struct qhdr {
  199.     char tos;
  200.     uint32 gateway;
  201. };
  202. #endif
  203.    
  204. #if defined(DRSI) || defined(EAGLE) || defined(PC_EC) || defined(HAPN) || defined(PC100)
  205. extern char Noipaddr[];
  206. #endif
  207. extern struct mbuf *Hopper;
  208.  
  209. /* In iface.c: */
  210. struct iface *if_lookup (const char *name);
  211. struct iface *ismyaddr (uint32 addr);
  212. int if_detach (struct iface *ifp);
  213. int setencap (struct iface *ifp,const char *mode);
  214. char *if_name (struct iface *ifp,const char *comment);
  215. int bitbucket (struct iface *ifp,struct mbuf *bp);
  216. int dosetflag (int argc,char *argv[],void *p,int flagtoset, int AX25only);
  217. int mask2width (uint32 mask);         /* Added N0POY, for rip code */
  218.  
  219. /* In config.c: */
  220. int net_route (struct iface *ifp,int type,struct mbuf *bp);
  221.  
  222. #endif    /* _IFACE_H */
  223.